//
//  YGLoginBLL.m
//  yuanshangyiliao
//
//  Created by icholab on 2021/3/15.
//

#import "YGLoginBLL.h"
#import "CNHTTPManager.h"
//#import "YGLogoModel.h"
@implementation YGLoginBLL

+ (void)requestLogoWithSuccess:(void(^)(YGLogoModel *model))successBlock fail:(void(^)(NSError *error))failBlock{
   
    [[CNHTTPManager shared] GET:YG_LOGIN_LOGO_URL parameters:nil success:^(id responeObj) {
        NSDictionary *data = [responeObj objectForKey:@"data"];
        YGLogoModel *model =  [[YGLogoModel alloc] initWithDictionary:data error:nil];
        if (successBlock) {
            successBlock(model);
        }
    } failure:^(NSError *error, NSString *errorDes) {
        if (failBlock) {
            failBlock(error);
        }
    }];
}

+ (void)requestLoginWithPhone:(NSString *)phone pwd:(NSString *)pwd success:(void(^)(YGUserInfoModel *model))successBlock fail:(void(^)(NSError *error))failBlock{
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    [dic setObject:pwd forKey:@"password"];
    [dic setObject:phone forKey:@"phone"];

    [[CNHTTPManager shared] GET:YG_LOGIN_LOGIN_URL parameters:dic success:^(id responeObj) {
        NSDictionary *data = [responeObj objectForKey:@"data"];
        YGUserInfoModel *model =  [[YGUserInfoModel alloc] initWithDictionary:data error:nil];
        [[UserInfoManager shareInstance] configureUserInfo:model];
        if (successBlock) {
            successBlock(model);
        }
    } failure:^(NSError *error, NSString *errorDes) {
        
    }];
}
@end
